const path = require('path')
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import NameBuildPlugin from './nameBuildPlugin'
// https://vitejs.dev/config/
export default defineConfig(env => {
  return {
    plugins: [
      vue(),
      NameBuildPlugin
    ],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "src"),
      }
    },
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true,
        }
      }
    },
    optimizeDeps: {
      include: ["@ant-design/icons-vue"],
    },

    build: {
      sourcemap: false,
      cssCodeSplit: true,
    },
    server: {
      proxy: {
        '^/api/.*': {
          changeOrigin: true,
          target: 'http://127.0.0.1:8085',
          rewrite: (path) => path.replace(/^\/api/, '')
        },
      }
    },
  }
})
